<div id="answered-question">
  <div class="row">

  <% user = user || @user # allow overriding w/ local variable %>

  <% @commented_questions&.each_with_index do |question,i| %>
    <% comments = if user then question&.comments.where(uid: user.uid) else question.comments end %>
    <div class="col-lg-4" style="margin-top:30px;">
      <div class="note note-pane note-answer">
        <div class="header-icon"><i class="fa fa-question-circle"></i></div>
        <h4><a href="<%= question.path(:question) %>"><%= question.title %></a></h4>
        <p>
          <a href="/profile/<%= question.author.name %>"><%= question.author.name %></a>
          asked about <span style="color:#888;"><%= time_ago_in_words(question.created_at) %> ago</span>
        </p>
        <div class="text-center"><span id="question-<%= question.nid %>-toggle" class="btn btn-outline-secondary btn-sm">Comments <%= if user then "by #{user.name}" end %><i class="fa fa-caret-down"></i></span></div>
        <div id="question-<%= question.nid %>" class="user-answer">
          <% comments.each do |comment| %>
            <p>commented on <a href="<%= question.path(:question) %>#c<%= comment.cid %>" style="color:#888;"><%= Time.at(comment.timestamp).strftime("%b %d, %Y") %></a><span class="float-right"><i class="fa fa-check-square" style="color: #FFEB3B;"></i> <%= comment.likers.length %></span></p>
          <% end %>
          <a href="<%= question.path(:question) %>#comments">Show all <%= question.comments.count %> comments &raquo;</a>
        </div>
      </div>
    </div>
  <% if ((i+1)/3.0).to_i == ((i+1)/3.0) %>
  </div>
  <hr class="d-lg-none grid" />
  <div class="row">
  <% end %>
  <script type="text/javascript">
    $('#question-<%= question.nid %>-toggle').on('click',function(){
      $('#question-<%= question.nid %>').toggle(300);
      $(this).toggleClass('active');
    });
  </script>
  <% end %>
  </div>
  <div class="text-center">
<% if @pagy %>
  <%== pagy_bootstrap_nav @pagy %>
<% else %>
  <%= will_paginate @questions, :renderer => WillPaginate::ActionView::BootstrapLinkRenderer unless @unpaginated || @questions.empty? %>
<% end %>
</div>
</div>
